package jy.game.components.save;


import java.util.ArrayList;
import java.util.Arrays;

import jy.game.components.item.JyItemInstance;
import jy.game.components.wuxue.JyTrigger;
import wx.xml.simpleframework.xml.Attribute;
import wx.xml.simpleframework.xml.Element;
import wx.xml.simpleframework.xml.Root;

@Root(name = "item")
public class JyGameSaveItem {

    @Attribute(name = "n") public String      name;
    @Attribute(name = "c") public int         count;
    @Element(name = "t") public   JyTrigger[] triggers;

    JyGameSaveItem(String name, JyTrigger[] triggers, int count) {
        this.name = name;
        this.triggers = triggers;
        this.count = count;
    }

    public JyItemInstance Generate() {
        JyItemInstance itemInstance = new JyItemInstance();
        itemInstance.setName(this.name);

        itemInstance.additionTriggers = ((this.triggers != null) ? Arrays.asList(this.triggers) : new ArrayList<>());
        itemInstance.initBind();
        return itemInstance;
    }

}